<template>
  <div style="width: 280px;margin: 0 auto;position: relative; top: 60px">
    <h2 style="width: 145px;margin: 0 auto">学生选课系统</h2>
    <br/>
    用户名：<el-input v-model="logindata.username" placeholder="请输入用户名" style="width: 200px"></el-input>
    <br/><br/>
    密码：<el-input v-model="logindata.password" placeholder="请输入密码" style="width: 200px; position: relative; right: -16px" show-password></el-input>
    <br/>
    <br/>
    <div style="width:60px;margin: 0 auto;">
      <el-button @click="login">登录</el-button>
    </div>
  </div>



</template>

<script>
export default {
  data(){
    return{
      logindata: {
        username: '',
        password: '',
     }
    }
  },
  methods: {
    login() {
      axios.post('/user/login/'+this.logindata.username+'/'+this.logindata.password,{},{withCredentials: true}).then(res=> {
        if(res.data.code===10000){
          console.log(res);
          this.$message.success(res.data.msg);
          this.$router.push('/user');
        }else{
          this.$message.error(res.data.msg);
        }
      })
    },
    register(){
      this.$router.push('/register')
    }

  }
}
</script>

<style scoped>

</style>